package BaseDatos;

/**
 * @author Angel Lopez
 */
public interface QueriesMySQL {
    
    
    public static final String INSERT_GAME = "INSERT INTO GAMES (ID_OWNER, NAME_GAME, DATE_START, DATE_FINISH) VALUES (?, ?, SYSDATE(),SYSDATE())";
    public static final String SELECT_GAME_LAST_INSERT = "SELECT DISTINCT LAST_INSERT_ID() FROM GAMES";
    public static final String DELETE_GAME = "UPDATE GAMES SET ACTIVE = 0 (WHERE ID_GAME = ?)";
    public static final String UPDATE_GAME_FINISH_DATE = "UPDATE GAMES SET DATE_FINISH = SYSDATE() WHERE(ID_GAME = ?)";
    public static final String UPDATE_GAME_FINISH = "UPDATE GAMES SET ID_WINNER = ?, DATE_FINISH = SYSDATE() WHERE(ID_GAME = ?)";
    public static final String SELECT_GAMES = "SELECT * FROM GAMES ORDER BY ID_GAME";
    public static final String SELECT_ACTIVE_GAMES = "SELECT * FROM GAMES WHERE DATE_START=DATE_FINISH ORDER BY ID_GAME";
    
    public static final String INSERT_USER = "INSERT INTO USERS (NICK, PASS, EMAIL, TYPE_USER) VALUES (?,?,?,?)";
    public static final String SELECT_USER_LAST_INSERT = "SELECT DISTINCT LAST_INSERT_ID() FROM USERS";
    public static final String DELETE_USER = "UPDATE USERS SET TYPE_USER=-1 WHERE (ID_USER = ?)";
    public static final String UPDATE_USER = "UPDATE USERS SET NICK = ?, PASS = ?, EMAIL = ?, TYPE_USER = ? WHERE (ID_USER = ?)";
    public static final String SELECT_USER_ONE = "SELECT * FROM USERS WHERE (ID_USER = ?)";
    public static final String SELECT_USER_ONE_NICK = "SELECT * FROM USERS WHERE (NICK = ?)";
    public static final String SELECT_USER_LOGIN = "SELECT TYPE_USER FROM USERS WHERE (PASS = ? AND NICK = ?)";
    public static final String SELECT_USERS = "SELECT * FROM USERS ORDER BY ID_USER";
    
    public static final String INSERT_PLAYER = "INSERT INTO GAMES_USERS (ID_GAME_PLAYED, ID_USER_PLAYED, DATE_JOIN) VALUES (?, ?, SYSDATE())";
    public static final String SELECT_PLAYERS = "SELECT ID_GAME_PLAYED, NICK, DATE_JOIN FROM GAMES_USERS, USERS WHERE (ID_USER_PLAYED = ID_USER) ORDER BY ID_GAME_PLAYED";
    //public static final String SELECT_PLAYERS = "SELECT ID_GAME_PLAYED, ID_USER_PLAYED FROM PLAYED";
    
}
